/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.webos.java.root;

/**
 *
 * @author kostya
 */
public class Utils {
    public static String trim(String aString){
        return trim(aString, "");
    }
    public static String trim(String aString, String _default){
        if(aString==null)
            return _default;
        aString = aString.trim();
        if("".equals(aString))
            return _default;
        while(aString.charAt(0)=='\t' || aString.charAt(0)=='\n' || aString.charAt(0)==' '){
            aString = aString.substring(1);
            if("".equals(aString))
                return _default;
        }
        while(aString.charAt(aString.length()-1)=='\t' ||
                aString.charAt(aString.length()-1)=='\n' || aString.charAt(aString.length()-1)==' '){
            aString = aString.substring(0, aString.length()-2);
            if("".equals(aString))
                return _default;
        }
        return aString;
    }
}
